package com.example.manpower.Controller;

import com.example.manpower.Dto.DepartmentStats;
import com.example.manpower.Entity.Department;
import com.example.manpower.Server.DepartmentService;
import com.example.manpower.Util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/department")
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;

    @PostMapping("/add")
    public Result add(@RequestBody Department department){
        return departmentService.add(department);
    }
    //分页查询
    @GetMapping("/select")
    public Result select(DepartmentStats departmentStats){
        return departmentService.select(departmentStats);
    }
    @DeleteMapping("/delete")
    public Result delete(Department department){
        return departmentService.delete(department);
    }
    @PutMapping("/update")
    public Result update(@RequestBody Department department){
        return departmentService.updateOne(department);
    }

    //查询所有的部门给前端用作下拉框选择
    @GetMapping("/selectall")
    public Result selectall(Department department) {
        return departmentService.selectall(department);
    }
}
